﻿@{
    ViewBag.Title = "信息模块--编辑信息";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/js/simditor/css/simditor.css" rel="stylesheet" />
<script src="~/Content/js/simditor/js/module.min.js"></script>
<script src="~/Content/js/simditor/js/hotkeys.min.js"></script>
<script src="~/Content/js/simditor/js/uploader.min.js"></script>
<script src="~/Content/js/simditor/js/simditor.min.js"></script>
<style>
    .simditor .simditor-body , .editor-style{
      min-height:450px;
    }
</style>

<form id="form1">
    <input type="hidden" id="F_Id" name="F_Id"/>
    <table class="form">
        <tr>
            <th class="formTitle">类型</th>
            <td class="formValue">
                <select id="F_TypeId" name="F_TypeId" class="form-control required">
                    <option value="0" selected="selected">常规</option>
                    <option value="1">置顶</option>
                    <option value="2">系统</option>
                </select>
            </td>
        </tr>
        <tr>
            <th class="formTitle">标题</th>
            <td class="formValue">
                <input id="F_Title" name="F_Title" type="text" class="form-control required" placeholder="请输入标题"/>
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">
                内容
            </th>
            <td class="formValue">
                <textarea id="F_Content" name="F_Content" class="form-control"></textarea>
            </td>
        </tr>
    </table>
</form>

<script type="text/javascript">
    var editor;
    var keyValue = $.request("keyValue");
    $(function () {
        editor = new Simditor({
            textarea: $('#F_Content'),
            toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent'],
            upload: {
                url: '/ProductManage/Product/EditorUpload', //文件上传的接口地址
                params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                fileKey: 'fileDataFileName', //服务器端获取文件数据的参数名
                connectionCount: 3,
                leaveConfirm: '正在上传文件'
            }
        });
        editor.Width = 1000;
        if (!!keyValue) {

            $.ajax({
                url: "/InformationCenter/News/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                cache: false,
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    editor.setValue(data["F_Content"]);
                    $("#F_Id").val(data.F_Id);
                }
            });
        }
    });

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/InformationCenter/News/SubmitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function() {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
                $.currentWindow().$(".toolbar .operate").find('.close').click();
            }
        });
    }

</script>